package com.evergrande.mybatis.service.impl;

import com.evergrande.mybatis.model.ExpandUser;
import com.evergrande.mybatis.service.ExpandUserService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.StringUtil;

import java.util.List;

/**
 * Created by yyccb on 2016-8-17.
 */
@Service("expandUserService")
public class ExpandUserServiceImpl extends BaseService<ExpandUser> implements ExpandUserService {
    /**
     * private Integer id;
     * private String mobileNo;
     * private String username;
     * private Integer isReg;
     * private Date regDate;
     * private Integer isRealname;
     * private Integer isTieCard;
     * private Integer isTrans;
     * private String scanCodeRec;
     * private Date rebateExpireDate;
     * private Date createTs;
     * private Date updateTs;
     */

    @Override
    public List<ExpandUser> selectListByExpandUser(ExpandUser expandUser, Integer page, Integer rows) {
        Example example = new Example(ExpandUser.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtil.isNotEmpty(expandUser.getUsername())) {
            criteria.andLike("username", "%" + expandUser.getUsername() + "%");
        }
        if (StringUtil.isNotEmpty(expandUser.getMobileNo())) {
            criteria.andLike("mobileNo", "%" + expandUser.getMobileNo() + "%");
        }
        if (expandUser.getId() != null) {
            criteria.andEqualTo("id", expandUser.getId());
        }
        //分页查询
        PageHelper.startPage(page, rows);
        return selectByExample(example);
    }
}
